package com.vpclub.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author : leimingchao
 * @date Date : 2021年07月05日 21:21
 */
@WebServlet(value = "/hello")
public class HelloServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.getWriter().write("hello.....");
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(Thread.currentThread() + "start....");
        try {
            this.sayHello();
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.doPost(req,resp);
        System.out.println(Thread.currentThread() + "end....");
    }

    public void sayHello() throws Exception {
        System.out.println(Thread.currentThread() + "processing....");
        Thread.sleep(3000);
    }
}
